package com.my.hive;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class HiveJDBC {

    public static void main(String[] args) throws Exception {
        String driver = "org.apache.hive.jdbc.HiveDriver";
        String url = "jdbc:hive2://hadoop102:10000/default";
        Class.forName(driver);
        Connection connection = DriverManager.getConnection(url, "root", "000000");
        Statement statement = connection.createStatement();
        statement.execute("SHOW DATABASES");
        ResultSet resultSet = statement.getResultSet();
        while (resultSet.next()){
            System.out.println(resultSet.getString(1));
        }
    }
}
